<?php
// +----------------------------------------------------------------------
// | Bwsaas
// +----------------------------------------------------------------------
// | Copyright (c) 2015~2020 http://www.buwangyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Gitee ( https://gitee.com/buwangyun/bwsaas )
// +----------------------------------------------------------------------
// | Author: buwangyun <hnlg666@163.com>
// +----------------------------------------------------------------------
// | Date: 2020-9-28 10:55:00
// +----------------------------------------------------------------------

namespace buwang\middleware;

use buwang\interfaces\MiddlewareInterface;
use buwang\traits\JsonTrait;

/**
 * 系统权限访问管理
 * Class Auth
 * @package app\admin\middleware
 */
class SignCheck implements MiddlewareInterface
{
    use JsonTrait;

    /**
     * @param $request
     * @param Closure $next
     * @return \buwang\traits\Respone|mixed|\think\response\Redirect
     */
    public function handle($request, \Closure $next)
    {
        //var_dump($request->header('request-app'));die;
        //var_dump('000000');die;
        return $next($request);
//        if(empty($request->param('sign/s'))){
//            $code = 401;
//            $msg  = '没有验证签名';
//        }else{
//            $secret = $this->miniapp->service_id;
//            if(empty($var['publickey']) && empty($secret)){
//                $code  = 403;
//                $msg = '签名秘钥或公钥错误';
//            }else{
//                $sign = Sign::makeSign($var,$secret,$signType);
//                if($var['sign'] == $sign){
//                    $code = 200;
//                    $msg = '成功';
//                }else{
//                    $code = 403;
//                    $msg = '参数验证失败';
//                }
//            }
//        }
//        return ['msg' => $msg,'code' => $code];


//
//        $token = $request->server('HTTP_TOKEN', (string)$request->request('token',  cookie('token')));
//        if($token){
//            $user = self::decodeToken($token);//解析token,获取用户信息
//
//            $request->user = $user;
//
//            return $next($request);
//        }
//
//        //未登录结果返回
//        if($request->isGet() || $request->isPost()){//ajax请求返回code
//            return $this->code(401)->error('no login');
//        }else{//模板解析时重定向至登录页面
//            return redirect('/manage/admin/login');
//        }
    }
}
